#region (c) 2014 THN Solutions LLC. - All rights reserved
/*
THN DATA ABSTRACTION LAYER version 1

Copyright (c) 2014, THN Solutions LLC. ( www.ThnSolutions.com )
Author: Nguyễn, M. Hải                 ( www.Minh-Hai.com     )
All rights reserved.

This library is dual-licensed.
  + For commercial software, please obtain a commercial license from THN Solutions LLC.

  + For free software, this library is licensed under GPL version 3. A summary of GPLv3 is
    listed below. You should also find a copy of GPLv3 as file License_GPLv3.txt included
	with the source-code files.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License version 3 as published by
    the Free Software Foundation  of the License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#endregion

#region Using directives
using System;
using System.Data;
using Thn.Data.Mapping;
using Thn.Data.Exceptions;
#endregion

namespace Thn.Data.Database.Sql.Dialect
{
    /// <summary>
    /// A specific dialect for SQL-supported databases
    /// </summary>
    public interface ISqlDialect
    {
        #region Create Connection
        /// <summary>
        /// Construct a database specific connection instance
        /// </summary>
        IDbConnection CreateConnection();
        #endregion

        #region Create command
        /// <summary>
        /// Construct a database specific command instance
        /// </summary>
        IDbCommand CreateCommand();        
        #endregion

        #region Create Parameter
        /// <summary>
        /// Construct a database specific parameter instance
        /// </summary>
        /// <param name="paramName">Name of parameter</param>
        /// <param name="valueType">.NET type of parameter's value</param>
        IDataParameter CreateParameter(string paramName, Type valueType);

        ///// <summary>
        ///// Construct a database specific parameter instance
        ///// </summary>
        ///// <param name="attribute">The attribute mapping</param>
        //IDataParameter CreateParameter(AttributeMap attribute);
        #endregion

        #region To Data Type
        /// <summary>
        /// Get the data type equivalent of a .NET type
        /// </summary>
        /// <param name="map">mapping for an attribute</param>
        object GetDataAttributeType(AttributeMap map);
        #endregion

        #region To Data Type String
        /// <summary>
        /// Gets the string version of data type equivalent to a .NET type
        /// </summary>
        /// <param name="map">mapping for an attribute</param>
        string GetDataAttributeAsString(AttributeMap map);
        #endregion

        #region Support Multi-Command
        /// <summary>
        /// Checks whether this database variant accepts multiple query commands at once
        /// </summary>
        bool SupportsMultipleCommands
        { get;}
        #endregion

        #region SqlStrings
        /// <summary>
        /// Gets Sql string constants specific to this dialect
        /// </summary>
        SqlDialectStrings SqlStrings
        { get;}
#endregion

        #region Parse Exception
        /// <summary>
        /// Parse a database specific exception to standard one (known to this data layer)
        /// </summary>
        /// <param name="error">original exception</param>
        /// <returns>standardized exception</returns>
        DataExceptionBase ParseException(Exception error);
        #endregion
    }
}

